package com.sharemarking.platform;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import com.sharemarking.system.mapper.MemberMapper;
import com.sharemarking.system.properties.CosProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

//import com.aliyun.oss.OSSClient;
//import com.sharemarking.system.properties.AliOSSProperties;
//import com.sharemarking.system.properties.AliSecretProperties;

@SpringBootApplication
@EnableCaching
@EnableScheduling
@EnableAsync
@MapperScan(basePackageClasses= MemberMapper.class)
public class Application {
	
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
//	@Autowired
//	private AliOSSProperties prop;
//
//	@Autowired
//	private AliSecretProperties sProp;
//
	@Autowired
	private CosProperties cop;
//
//	@Bean
//	public OSSClient ossClient(){
//		return new OSSClient(prop.getEndpoint(), sProp.getAccessKeyId(), sProp.getAccessKeySecret());
//	}



	@Bean
	public COSClient cosClient(){
		COSCredentials cred = new BasicCOSCredentials(cop.getSecretid(), cop.getSecretkey());
		Region region = new Region(cop.getRegion());
		ClientConfig clientConfig = new ClientConfig(region);
		COSClient cosClient = new COSClient(cred, clientConfig);
		return cosClient;
	}
}
